/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jogo.Entidade;

import jogo.Elemento;
import java.awt.Graphics;
import java.awt.Graphics2D;
import jogo.sprite.Sprite;
import sun.util.locale.ParseStatus;

/**
 *
 * @author Glauco
 */
public class Tiro extends TiroMovimento {

    private Sprite e;
    private boolean vivo;
    public static double GRAVITY_EFFECT = 0.2;
    public static int Quadrante = 0;
    private double maxvx, maxvy;
    

    //Construtor utilizado apenas por motivos de compilação , chamado na frmJogo
    public Tiro() {
        super(1, 1, 1, 1, 1);
    }

    public Tiro(Sprite e, int sx, int sy, int r, double dx, double dy) {
        super(sx, sy, r, dx, dy);

        this.e = e;
        e.vivo = true;

        super.setMovimento(true);
    }

    @Override
    public void desenhar(Graphics2D g) {

        e.upDate(g, super.getX(), super.getY(), System.currentTimeMillis());
        vivo = e.vivo;
    }

    @Override
    public void mover() {


        double valueX, valueY;
        valueX = super.getDx();
        valueY = super.getDy();                


        switch (Quadrante) {
            case 0:
                //MU                
                setMovimento(getDx(), getDy());                
                break;
            case 1:                
                //1º Quad.                
                //if (Math.abs(getDx() - GRAVITY_EFFECT) < Math.abs(maxvx)) {
                    valueX = getDx() - GRAVITY_EFFECT;
                //}
                //if (Math.abs(getDy() + GRAVITY_EFFECT) < Math.abs(maxvy)) {
                    valueY = getDy() + GRAVITY_EFFECT;
                //}

                break;
            case 2:
                //2º Quad.

                //if (Math.abs(getDx() + GRAVITY_EFFECT) < Math.abs(maxvx)) {
                    valueX = getDx() + GRAVITY_EFFECT;
                //}
                //if (Math.abs(getDy() + GRAVITY_EFFECT) < Math.abs(maxvy)) {
                    valueY = getDy() + GRAVITY_EFFECT;
                //}

                break;
            case 3:
                //3º Quad.
                //if (Math.abs(getDx() + GRAVITY_EFFECT) < Math.abs(maxvx)) {
                    valueX = getDx() + GRAVITY_EFFECT;
                //}
                //if (Math.abs(getDy() - GRAVITY_EFFECT) < Math.abs(maxvy)) {
                    valueY = getDy() - GRAVITY_EFFECT;
                //}

                break;
            case 4:
                //4º Quad.
                //if (Math.abs(getDx() - GRAVITY_EFFECT) < Math.abs(maxvx)) {
                    valueX = getDx() - GRAVITY_EFFECT;
                //}
                //if (Math.abs(getDy() - GRAVITY_EFFECT) < Math.abs(maxvy)) {
                    valueY = getDy() - GRAVITY_EFFECT;
                //}

                break;

            case 5:
                //<-
                //if (Math.abs(getDx() - GRAVITY_EFFECT) < Math.abs(maxvx)) {
                    valueX = getDx() - GRAVITY_EFFECT;
                //}

                break;

            case 6:
                // |
                // V                
                //if (Math.abs(getDx() + GRAVITY_EFFECT) < Math.abs(maxvy)) {
                    valueY = getDy() + GRAVITY_EFFECT;
                //}

                break;

            case 7:
                //->
                //if (Math.abs(getDy() + GRAVITY_EFFECT) < Math.abs(maxvy)) {
                    valueY = getDy() + GRAVITY_EFFECT;
                //}

                break;

            case 8:
                // A
                // |                
                //if (Math.abs(getDy() - GRAVITY_EFFECT) < Math.abs(maxvy)) {
                    valueY = getDy() - GRAVITY_EFFECT;
                //}


                break;

        }

        setMovimento(valueX, valueY);

        super.mover();
    }

    /**
     * @return the e
     */
    public Sprite getE() {
        return e;
    }

    /**
     * @param e the e to set
     */
    public void setE(Sprite e) {
        this.e = e;
    }

    /**
     * @return the vivo
     */
    public boolean isVivo() {
        return vivo;
    }

    /**
     * @return the maxvx
     */
    public double getMaxvx() {
        return maxvx;
    }

    /**
     * @param maxvx the maxvx to set
     */
    public void setMaxvx(double maxvx) {
        this.maxvx = maxvx;
    }

    /**
     * @return the maxvy
     */
    public double getMaxvy() {
        return maxvy;
    }

    /**
     * @param maxvy the maxvy to set
     */
    public void setMaxvy(double maxvy) {
        this.maxvy = maxvy;
    }

    /**
     * @param vivo the vivo to set
     */
    public void setVivo(boolean vivo) {
        this.vivo = vivo;
    }

    /**
     * @return the dx
     */
    public double getDx() {
        return super.getDx();
    }

    /**
     * @param dx the dx to set
     */
    public void setDx(double dx) {
        super.setDx(dx);
    }

    /**
     * @return the dy
     */
    public double getDy() {
        return super.getDy();
    }

    /**
     * @param dy the dy to set
     */
    public void setDy(double dy) {
        super.setDy(dy);
    }
}
